<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core">

<ui:composition template="/WEB-INF/template/template.xhtml">
	<ui:define name="content">
		<f:view>
			<h:form id="resourceForm">
				<div class="middle">
					<h:messages class="myError" id="errors" />
					<h:outputText value="&lt;br/&gt;" escape="false" />
					<h3>
						<h:outputText value="#{msg.OM_resourcecrud_manage}"></h:outputText>
					</h3>
					<h:outputText value="&lt;br/&gt;" escape="false" />

					<h:outputText value="#{msg.OM_resourcecrud_resources}" />
					<!-- 				Select resource type radiobuttons -->
					<h:selectOneRadio styleClass="middle"
						value="#{resourceBean.selectTypeRadio}">
						<f:ajax execute="@this" listener="#{resourceBean.resetEdit}"
							render="contentGrid errors"></f:ajax>
						<f:ajax listener="#{techresourceBean.resetEdit}"></f:ajax>
						<f:selectItem itemValue="1" itemLabel="Resources" />
						<f:selectItem itemValue="2" itemLabel="Tech Resources" />
					</h:selectOneRadio>
				</div>




				<!-- 			Content (filtered by radiobuttons) -->
				<h:panelGrid id="contentGrid" class="panelGrid">

					<!-- 				Resource Content -->
					<h:panelGrid id="resT"
						rendered="#{resourceBean.selectTypeRadio eq '1'}">

						<h:outputText value="#{msg.OM_resourcecrud_search}" />
						<h:inputText id="searchValueR" value="#{resourceBean.searchKey}">
							<f:ajax event="keyup" execute="searchValueR"
								render="resourceTable" listener="#{resourceBean.applyFilter}" />
						</h:inputText>
						<h:commandButton value="#{msg.OM_resourcecrud_search}"
							styleClass="button">
							<f:ajax execute="searchValueR" render="resourceTable"
								listener="#{resourceBean.applyFilter}" />
						</h:commandButton>

						<!-- 					New Resource Fields -->
						<h:commandButton value="#{msg.OM_resourcecrud_newres}"
							styleClass="button"
							disabled="#{resourceBean.editResourceDTO.id != 0}">
							<f:ajax render="newResourceFields"
								listener="#{resourceBean.showNewFields}"></f:ajax>
						</h:commandButton>

						<h:panelGrid id="newResourceFields" columns="2">
							<h:panelGroup rendered="#{resourceBean.showNew}">
								<h:outputText value="#{msg.OM_resourcecrud_resname}&lt;br&gt;"
									escape="false" />
								<h:inputText style="width:200px;" label="Name"
									value="#{resourceBean.newResourceDTO.name}"
									validatorMessage="#{msg.OM_resourcecrud_reqMessage1}">
									<f:validateLength minimum="2"
										disabled="#{resourceBean.selectTypeRadio == 2 and not managerPageBean.page eq 'manageResources'}" />
								</h:inputText>
								<h:commandButton value="#{msg.OM_resourcecrud_add}"
									styleClass="button">
									<f:ajax render="contentGrid errors" execute="newResourceFields"
										listener="#{resourceBean.addNewResource}" />
								</h:commandButton>
							</h:panelGroup>
						</h:panelGrid>

						<h:outputText value="&lt;br/&gt;" escape="false"
							rendered="#{resourceBean.feedback == ' '}" />
						<h:outputText id="feedbackMessageR"
							value="#{resourceBean.feedback}" />

						<h:dataTable id="resourceTable" class="table" style="width:450px;"
							columnClasses="colW150,colW150,colW150" rowClasses="colH50"
							value="#{resourceBean.resourceDTOs}" var="resources" border="1">
							<h:column>
								<f:facet name="header">
									<h:outputText value="#{msg.OM_resourcecrud_resn}" />
								</f:facet>
								<h:outputText value="#{resources.name}"
									rendered="#{resourceBean.editResourceDTO.id != resources.id}" />
								<h:inputText style="width:130px;"
									value="#{resourceBean.editResourceDTO.name}"
									rendered="#{resourceBean.editResourceDTO.id == resources.id}"
									validatorMessage="#{msg.OM_resourcecrud_reqMessage1}">
									<f:validateLength minimum="2"></f:validateLength>
								</h:inputText>
							</h:column>
							<h:column>
								<f:facet name="header">
									<h:outputText value="#{msg.OM_resourcecrud_edit}" />
								</f:facet>
								<h:panelGroup
									rendered="#{resourceBean.editResourceDTO.id != resources.id}">
									<h:commandButton class="editBtn" value="Edit" immediate="true"
										actionListener="#{resourceBean.markForEdit}"
										action="mainManager.xhtml">
										<f:attribute name="editResource" value="#{resources}" />
									</h:commandButton>
								</h:panelGroup>
								<h:panelGroup
									rendered="#{resourceBean.editResourceDTO.id == resources.id}">
									<h:commandButton value="#{msg.OM_resourcecrud_save}"
										styleClass="button" actionListener="#{resourceBean.saveEdit}"
										action="mainManager.xhtml">
									</h:commandButton>
									<h:commandButton value="#{msg.OM_resourcecrud_cancel}"
										immediate="true" styleClass="button"
										actionListener="#{resourceBean.cancelEdit}"
										action="mainManager.xhtml">
									</h:commandButton>
								</h:panelGroup>
							</h:column>
							<h:column>
								<f:facet name="header">
									<h:outputText value="#{msg.OM_resourcecrud_delete}" />
								</f:facet>
								<h:commandButton class="trashBtn" value="Delete"
									disabled="#{resourceBean.editResourceDTO.id != 0}"
									action="mainManager.xhtml" immediate="true"
									actionListener="#{resourceBean.performDelete}"
									onclick="#{msg.OM_resourcecrud_confMessage1}">
									<f:attribute name="deleteResource" value="#{resources}" />
								</h:commandButton>

							</h:column>
						</h:dataTable>

					</h:panelGrid>

					<!-- 				Techresource Content -->
					<h:panelGrid rendered="#{resourceBean.selectTypeRadio eq '2'}">

						<h:outputText value="#{msg.OM_resourcecrud_search}" />
						<h:inputText id="searchValueT"
							value="#{techresourceBean.searchKey}">
							<f:ajax event="keyup" execute="searchValueT"
								render="techresourceTable"
								listener="#{techresourceBean.applyFilter}" />
						</h:inputText>
						<h:commandButton value="#{msg.OM_resourcecrud_search}"
							styleClass="button">
							<f:ajax execute="searchValueT" render="techresourceTable"
								listener="#{techresourceBean.applyFilter}" />
						</h:commandButton>

						<!-- 					New Techresource Fields -->
						<h:commandButton value="#{msg.OM_resourcecrud_newtr}"
							styleClass="button"
							disabled="#{techresourceBean.editTechresourceDTO.id != 0}">
							<f:ajax render="newTechresourceFields"
								listener="#{techresourceBean.showNewFields}" />
						</h:commandButton>
						<h:panelGroup id="newTechresourceFields">
							<h:outputText rendered="#{techresourceBean.showNew}"
								value="#{msg.OM_resourcecrud_reqMessage2}" escape="false" />
							<h:panelGrid rendered="#{techresourceBean.showNew}" columns="2">
								<h:outputText value="#{msg.OM_resourcecrud_name}" />
								<h:inputText style="width:200px;"
									value="#{techresourceBean.newTechresourceDTO.name}"
									validatorMessage="#{msg.OM_resourcecrud_reqMessage1}">
									<f:validateLength minimum="2"
										disabled="#{not managerPageBean.page eq 'manageResources'}" />
								</h:inputText>

								<h:outputText value="#{msg.OM_resourcecrud_ip}" />
								<h:inputText style="width:200px;"
									value="#{techresourceBean.newTechresourceDTO.ip}"
									validatorMessage="#{msg.OM_resourcecrud_reqMessage3}">
									<f:validateRegex
										pattern="\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b"
										disabled="#{not managerPageBean.page eq 'manageResources'}" />
								</h:inputText>

								<h:outputText value="#{msg.OM_resourcecrud_idnumber}" />
								<h:inputText style="width:200px;"
									value="#{techresourceBean.newTechresourceDTO.idnumber}"
									required="true"
									requiredMessage="#{msg.OM_resourcecrud_reqMessage4}"
									validatorMessage="#{msg.OM_resourcecrud_reqMessage4}">
									<f:validateLongRange minimum="1" maximum="2147483647"
										disabled="#{not managerPageBean.page eq 'manageResources'}" />
								</h:inputText>

								<h:outputText value="#{msg.OM_resourcecrud_status}" />
								<h:inputText style="width:200px;"
									value="#{techresourceBean.newTechresourceDTO.status}"
									validatorMessage="#{msg.OM_resourcecrud_reqMessage5}">
									<f:validateRegex pattern="\bWorking\b|\bNot Working\b"
										disabled="#{not managerPageBean.page eq 'manageResources'}" />
								</h:inputText>

								<h:commandButton value="#{msg.OM_resourcecrud_add}"
									styleClass="button">
									<f:ajax render="contentGrid errors"
										execute="newTechresourceFields"
										listener="#{techresourceBean.addNewTechresource}" />
								</h:commandButton>
							</h:panelGrid>
						</h:panelGroup>

						<h:outputText value="&lt;br/&gt;" escape="false"
							rendered="#{techresourceBean.feedback == ' '}" />
						<h:outputText id="feedbackMessageT"
							value="#{techresourceBean.feedback}" />

						<!-- 					Techresource data table -->
						<h:dataTable id="techresourceTable" class="table"
							columnClasses="colW150,colW150,colW150,colW150,colW150,colW150,colW150"
							rowClasses="colH50" value="#{techresourceBean.techresourceDTOs}"
							var="techresources" border="1">
							<h:column>
								<f:facet name="header">
									<h:outputText value="#{msg.OM_resourcecrud_resn}" />
								</f:facet>
								<h:outputText value="#{techresources.name}"
									rendered="#{techresourceBean.editTechresourceDTO.id != techresources.id}" />
								<h:inputText style="width:130px;"
									value="#{techresourceBean.editTechresourceDTO.name}"
									rendered="#{techresourceBean.editTechresourceDTO.id == techresources.id}"
									validatorMessage="#{msg.OM_resourcecrud_reqMessage1}">
									<f:validateLength minimum="2"
										disabled="#{resourceBean.selectTypeRadio == 1 and not managerPageBean.page eq 'manageResources'}" />
								</h:inputText>
							</h:column>
							<h:column>
								<f:facet name="header">
									<h:outputText value="#{msg.OM_resourcecrud_ip}" />
								</f:facet>
								<h:outputText value="#{techresources.ip}"
									rendered="#{techresourceBean.editTechresourceDTO.id != techresources.id}" />
								<h:inputText style="width:130px;"
									value="#{techresourceBean.editTechresourceDTO.ip}"
									rendered="#{techresourceBean.editTechresourceDTO.id == techresources.id}"
									validatorMessage="#{msg.OM_resourcecrud_reqMessage3}">
									<f:validateRegex
										pattern="\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b"
										disabled="#{not managerPageBean.page eq 'manageResources'}" />
								</h:inputText>
							</h:column>
							<h:column>
								<f:facet name="header">
									<h:outputText value="#{msg.OM_resourcecrud_status}" />
								</f:facet>
								<h:outputText value="#{techresources.status}"
									rendered="#{techresourceBean.editTechresourceDTO.id != techresources.id}" />
								<h:inputText style="width:130px;"
									value="#{techresourceBean.editTechresourceDTO.status}"
									rendered="#{techresourceBean.editTechresourceDTO.id == techresources.id}"
									validatorMessage="#{msg.OM_resourcecrud_reqMessage5}">
									<f:validateRegex pattern="\bWorking\b|\bNot Working\b"
										disabled="#{not managerPageBean.page eq 'manageResources'}" />
								</h:inputText>
							</h:column>
							<h:column>
								<f:facet name="header">
									<h:outputText value="#{msg.OM_resourcecrud_domain}" />
								</f:facet>
								<h:outputText value="#{techresourceBean.domainOf(techresources).name}" />

							</h:column>
							<h:column>
								<f:facet name="header">
									<h:outputText value="#{msg.OM_resourcecrud_idnum}" />
								</f:facet>
								<h:outputText value="#{techresources.idnumber}"
									rendered="#{techresourceBean.editTechresourceDTO.id != techresources.id}" />
								<h:inputText style="width:130px;"
									value="#{techresourceBean.editTechresourceDTO.idnumber}"
									rendered="#{techresourceBean.editTechresourceDTO.id == techresources.id}"
									required="true"
									requiredMessage="#{msg.OM_resourcecrud_reqMessage4}"
									validatorMessage="#{msg.OM_resourcecrud_reqMessage4}">
									<f:validateLongRange minimum="1" maximum="2147483647"
										disabled="#{not managerPageBean.page eq 'manageResources'}" />
								</h:inputText>
							</h:column>
							<h:column>
								<f:facet name="header">
									<h:outputText value="#{msg.OM_resourcecrud_edit}" />
								</f:facet>
								<h:panelGroup
									rendered="#{techresourceBean.editTechresourceDTO.id != techresources.id}">
									<h:commandButton class="editBtn"
										value="#{msg.OM_resourcecrud_edit}" immediate="true"
										actionListener="#{techresourceBean.markForEdit}"
										action="mainManager.xhtml">
										<f:attribute name="editTResource" value="#{techresources}" />
									</h:commandButton>
								</h:panelGroup>
								<h:panelGroup
									rendered="#{techresourceBean.editTechresourceDTO.id == techresources.id}">
									<h:commandButton value="#{msg.OM_resourcecrud_save}"
										styleClass="button"
										actionListener="#{techresourceBean.saveEdit}"
										action="mainManager.xhtml">
									</h:commandButton>
									<h:commandButton value="#{msg.OM_resourcecrud_cancel}"
										styleClass="button" immediate="true"
										actionListener="#{techresourceBean.cancelEdit}"
										action="mainManager.xhtml">
									</h:commandButton>
								</h:panelGroup>
							</h:column>
							<h:column>
								<f:facet name="header">
									<h:outputText value="#{msg.OM_resourcecrud_delete}" />
								</f:facet>
								<h:commandButton class="trashBtn"
									value="#{msg.OM_resourcecrud_delete}"
									disabled="#{techresourceBean.editTechresourceDTO.id != 0}"
									immediate="true"
									actionListener="#{techresourceBean.performDelete}"
									onclick="#{msg.OM_resourcecrud_reqMessage6}">
									<f:attribute name="deleteTResource" value="#{techresources}"
										action="mainManager.xhtml" />
								</h:commandButton>
							</h:column>
						</h:dataTable>

					</h:panelGrid>
				</h:panelGrid>
			</h:form>
		</f:view>
	</ui:define>
</ui:composition>
</html>